import request from '@/utils/request'
// eslint-disable-next-line camelcase
export const getArticles = (channel_id, timestamp) => {
  // 如果函数没有写return那么它就有一个默认的值就是undefined
  return request({
    url: 'v1_0/articles', // 接口地址
    params: {
      channel_id,
      // 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
      timestamp
    }
  })
}
export const unLike = (articleId) => {
  return request({
    url: 'v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleId
    }
  })
}
export const report = (articleId, reportType) => {
  return request({
    method: 'POST',
    url: 'v1_0/article/reports',
    data: {
      target: articleId,
      type: reportType
    }
  })
}
export const getAllChannels = (articleId) => {
  return request({
    url: 'v1_0/channels',
    method: 'GET'
  })
}
export const addChannels = (channels) => {
  return request({
    url: '/v1_0/user/channels', // 接口地址
    method: 'PATCH',
    data: {
      channels
    }
  })
}
// 获取详情
export const getDetail = (articleId) => {
  return request({
    url: '/v1_0/articles/' + articleId// 接口地址

  })
}

// 取消点赞
export const deleteLick = id => {
  return request({
    method: 'DELETE',
    url: 'v1_0/article/likings/' + id
  })
}
// 添加点赞
export const addLick = id => {
  return request({
    method: 'POST',
    url: 'v1_0/article/likings',
    data: {
      target: id
    }
  })
}
